<%@page import="java.util.ArrayList"%>
<%@page import="sopt.engSearch.DaumSearchProc"%><%@page import="statics.SoptVars"%>
<%@page import="sopt.engSearch.NaverSearchProc"%>
<%@page import="comm.util.RequestManager"%>
<%@page import="comm.util.SoptHashMap"%>
<%@page import="sopt.engSearch.TranslateProc"%>
<%@page import="sopt.engSearch.YahooSearchProc"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	SoptHashMap hm = RequestManager.getRequest(request);
	System.out.println("RESULT CONTENT 안에 해쉬맵!+ㅁ+"+hm.toString());
	//String result = NaverSearchProc.getTranslatedResultSearch(hm,SoptVars.naverSearch_target_kin);
	String q = "";
	String translatedQ = "";
	String category = SoptVars.Menu_Category_Knowledge;
	int curPage = 1;
	int length = 5;
	
	
	if(hm.get("Q")!=null)q = hm.get("Q").toString();
	translatedQ = TranslateProc.getTranslatedString(q,SoptVars.ENG_TO_KOR);
	if(hm.get("CATEGORY")!=null)category = hm.get("CATEGORY").toString();
	if(hm.get("PAGE")!=null)curPage = Integer.parseInt(hm.get("PAGE").toString());
	if(hm.get("LENGTH")!=null)length = Integer.parseInt(hm.get("LENGTH").toString());
	
	if(category.equals(SoptVars.Menu_Category_Image))length=20;
	
	String result="";
	String shorcutQ = "";
	boolean failGetLocalInfoOriginQuery = false;
	
	//지역 검색 결과
   	
	
	if(category.equals(SoptVars.Menu_Category_Local)){ //지역검색만 야후
		result = YahooSearchProc.getTranslatedLocalResult(
	   			YahooSearchProc.getYahooPOISearchResult(q),
	   			curPage,SoptVars.Menu_Category_Local);
		if(result.length()==0){
			if(((SoptHashMap) NaverSearchProc.getShortcutUrl(q))!=null){
				failGetLocalInfoOriginQuery = true;
				shorcutQ = ((SoptHashMap) NaverSearchProc.getShortcutUrl(q)).get("LABEL").toString();
				
				result = YahooSearchProc.getTranslatedLocalResult(
			   			YahooSearchProc.getYahooPOISearchResult(shorcutQ),
			   			curPage,SoptVars.Menu_Category_Local);
			}
		}
	}else{
		System.out.println("=============검색 쿼리!!!!"+translatedQ);
		result = DaumSearchProc.getTranslatedSearchResult(DaumSearchProc.getResultDaumSearch(translatedQ,category,curPage,length),curPage,category);
	}
	
	curPage++;

	if(result.length()>0){ %>
		<%if(failGetLocalInfoOriginQuery){ %>
		<div style="color:orange;">We're cannot founds resuls for original query, this results for '<%=TranslateProc.getTranslatedString(shorcutQ,SoptVars.KOR_TO_ENG)%>'</div>
		<%} %>
		<%=result%>
	<%}else{%>
		<div style="color:orange;">Sorry, we're cannot founds any results.</div>
	<%}%>

